package uk.ac.aber.Blockmation.Actions;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;

import javax.swing.ImageIcon;
import uk.ac.aber.Blockmation.MainFrame;

/**
 * 
 * @author tom, alex
 */

public class ActionTwoFramesForward extends AbstractAction {

    private MainFrame mainFrame;
    private String path = "../icons/NoFrame.gif";

    public ActionTwoFramesForward(MainFrame mainFrame) {
        super("Two Forwards"); 
        this.mainFrame = mainFrame;
        
        // the below from settings class file or?!
        //putValue(SHORT_DESCRIPTION, tooltip);  // Will appear as tooltip text.
        //putValue(MNEMONIC_KEY, new Integer(mnemonic));
        
    }
        
    public void actionPerformed(ActionEvent e) {
        int index = mainFrame.getCurrentFrameIndex();

    	if (index < mainFrame.getMovieModel().size() - 2) {
            index += 2;
            mainFrame.setCurrentFrameIndex(index);
            mainFrame.getPad().setImage(mainFrame.getMovieModel().get(index));
        } else {
            System.err.println("Cannot go two frames forward.");
        }
    	
    }
    
    public void setImage () {
        int index = mainFrame.getCurrentFrameIndex();
        
        if (index < mainFrame.getMovieModel().size() - 2) {
            
            putValue(SMALL_ICON, new ImageIcon(mainFrame.getMovieModel().get(index+2).getScaledInstance(80, 80, 1)));
            
        } else {
            CreateImageIcon createImageIcon = new CreateImageIcon();
            putValue(SMALL_ICON, createImageIcon.create(path));
        }
    }


}
